#[macro_use]
extern crate tracing;

use mlogst::mlog_init;

use std::thread;
use std::time::Duration;

// 可能会把当前的日志文件删除了，要等到新的时间点才会再打印出日志

fn main() {
    let _guard = mlog_init(
        "./logs",
        32 * 1000,
        tracing_appender::rolling::Rotation::MINUTELY,
    );

    for i in 0..10 {
        info!("i: {}", i);
        warn!("i: {}", i);
    }

    // let mlog_folder = unsafe { MLOG_FOLDER.get().unwrap() };

    // 查看日志目录大小
    // println!("{:?}", mlog_size_get(mlog_folder));

    // let index_folder = mlog_folder.join("144");
    // println!("{:?}", mlog_delete_earliest_log(&index_folder));

    // 限制日志大小，从以前的日志开始删除
    // mlog_task();

    let mut count = 0;

    loop {
        error!("aoao count: {}", count);
        warn!("aoao count: {}", count);
        info!("aoao count: {}", count);
        debug!("aoao count: {}", count);
        trace!("aoao count: {}", count);

        count += 1;

        thread::sleep(Duration::from_secs(1));
    }
}
